home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 June
/
CHIP Haziran 2001.iso
/
prog
/
share
/
17
/
dings_e.exe
/
Compiler
/
Bin
/
DirectInput.h
< prev
next >
Wrap
C/C++ Source or Header
|
2001-02-06
|
2KB
|
60 lines
// --- DirectInput.h
// --- defines ---
#if !defined(DIRECTINPUT_CLASS_INCLUDED)
#define DIRECTINPUT_CLASS_INCLUDED
#include <dinputd.h>
#include <dinput.h>
#define HR(error) MAKE_HRESULT(1, 0x000, error)
#define DXIN_MAX_JOYSTICKS 4
#define DINPUT_OK 1
#define DINPUT_ERROR 0
#define CANT_CREATE_DINPUT HR(10)
#define NO_ACCESS_ON_KEYBOARD HR(11)
#define NO_ACCESS_ON_MOUSE HR(12)
// --- structure for mousedata ---
struct DIMOUSEDATA
{
short Button1, Button2, Button3;
short AccX, AccY;
};
BOOL FAR PASCAL g_EnumJoystick(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef);
static LPDIRECTINPUTDEVICE g_lpDID;
// --- class constructor ---
class DirectInput
{
public:
DirectInput();
~DirectInput();
HRESULT CreateDInput(HWND hWnd, HINSTANCE hInstance); // Init DInput
void GetKeyboardStatus(); // Freeze current buffer
bool GetKey(unsigned char Key); // Get DI-Key Status
bool AnyKey(); // Is Any Key Pressed?
char GetKeyChar(void); // Get the char that has been pressed
bool GetMouseData(DIMOUSEDATA *Data); // Freeze Mousedata to stuct
bool AnyMouse(); // Is any Mousebutton down?
bool GetJoystickData(DIJOYSTATE* Data, char num); // Get Josytick Information
private:
LPDIRECTINPUT lpDInput;
LPDIRECTINPUTDEVICE lpDIDKeyboard;
LPDIRECTINPUTDEVICE lpDIDMouse;
LPDIRECTINPUTDEVICE2 lpDIDJoystick[DXIN_MAX_JOYSTICKS];
protected:
BYTE m_KeyBuffer[256];
BYTE m_MapBuffer[256];
void DXtoVK(bool DXActive);
};
#endif // DIRECTINPUT_CLASS_INCLUDED